﻿using FluentValidation;
using System;
using System.Collections.Generic;
using System.Text;

namespace TL_Cloud.ViewModels.BookShop.BaseStudent
{
    class BaseStudentAddOrUpdateResourceValidator<T> : AbstractValidator<T>
          where T : BaseStudentBasicInfoResource
    {
        public BaseStudentAddOrUpdateResourceValidator()
        {
            RuleFor(x => x.StudentCode)
                 .NotNull()
                 .WithName("学号")
                 .WithMessage("required|{PropertyName}是必填的")
                 .MaximumLength(20)
                 .WithMessage("maxlength|{PropertyName}的最大长度是{MaxLength}");

            RuleFor(x => x.StudentName)
                .NotNull()
                .WithName("姓名")
                .WithMessage("required|{PropertyName}是必填的")
                .MaximumLength(20)
                .WithMessage("maxlength|{PropertyName}的最大长度是{MaxLength}");

            RuleFor(x => x.Email)
               .NotNull()
               .WithName("Email")
               .WithMessage("required|{PropertyName}是必填的")
               .MaximumLength(20)
               .WithMessage("maxlength|{PropertyName}的最大长度是{MaxLength}");

            RuleFor(x => x.HeadIcon)
               .MaximumLength(200)
               .WithMessage("maxlength|{PropertyName}的最大长度是{MaxLength}");

            RuleFor(x => x.Qq)
               .MaximumLength(20)
               .WithMessage("maxlength|{PropertyName}的最大长度是{MaxLength}");

            RuleFor(x => x.Telephone)
              .NotNull()
              .WithName("电话")
              .WithMessage("required|{PropertyName}是必填的")
              .MaximumLength(20)
              .WithMessage("maxlength|{PropertyName}的最大长度是{MaxLength}");

            RuleFor(x => x.WeiXinCode)
              .MaximumLength(20)
              .WithMessage("maxlength|{PropertyName}的最大长度是{MaxLength}");

        }
    }
}
